<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="f" uri="http://java.sun.com/jsf/core" %>
<%@taglib prefix="h" uri="http://java.sun.com/jsf/html" %>
<%@taglib prefix="rich" uri="http://richfaces.org/rich" %>
<%@taglib prefix="a4j" uri="http://richfaces.org/a4j" %>
<%@taglib prefix="c" uri="http://java.sun.com/jstl/core_rt" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<f:view>
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <link rel="stylesheet" type="text/css" href="../css/popup.css"/> 
            <link rel="stylesheet" type="text/css" href="../css/kapiform.css"/> 
            <script type="text/javascript" language="javascript" src="../scripts/jQuery/kapi.js"></script>
            <script type="text/javascript" language="javascript">
                var open_cur = 0;
                $j = jQuery.noConflict();
                $j(document).ready(function(){
                    $j('#fancybox-close').addClass('fancyboxClose');
                    var empString="";
          
                    var exbandbean = '<c:out value="${customerExpand.empString}"/>';
                    if(exbandbean!=null){
                        empString = exbandbean;
                    }else{
                        var custour ='<c:out value="${v030Controller.empString}"/>';
                        empString = custour;
                    }
          
           
                      
                    $j('.close').live('click',function(){
                        
                         if(empString=="customer4tour"){
                             window.location.href="customer4tour.jsp?<c:out value="${kapiMenu.md5url}"/>&action=clear";
                        }else
                        if(empString=="customerexpand"){
                            window.location.href="customerexpand.jsp?<c:out value="${kapiMenu.md5url}"/>&action=clear";
                        }else{
                           $j.fancybox.close();  
                        }
                    }); 
                    
                       
                    $j('.sendsmsexe').live('click',function(){
                        var mv302;
                        var mv305;
                        var tempold  =$j('.phoneold').text();                      
                        
                        message  = $j('.messagesms').val();  
                        var phone  ='<c:out value="${item.nv958}"/>';
                        var pn100  = '<c:out value="${item.pn100}"/>';
                        mv302=$j('.mv302').val();
                          
                        mv305=$j('.mv305').val();
                        var tempnew  = tempold+','+$j('.addphone').val();
                        if(mv302.length > 5){
                          
                            tempnew.split(',').each(function(e){
                                if(e.length>9){
                                    $j.ajax({
                                        url: "http://center.fibosms.com/Service.asmx/SendSMS?",
                                        type: "POST",
                                        data: {clientNo:"CL7793", clientPass:"ntis@sale@1234", phoneNumber:e, smsMessage:message, smsGUID:1,serviceType:4684},
                                        dataType: "json",
                                        beforeSend: function(x) {
                                                       
                                            if (x && x.overrideMimeType) {
                                                x.overrideMimeType("application/j-son;charset=UTF-8");
                                                //  $j('.returnss').text(x);
                                            }
                                        },
                                        complete: function(data){
                                                
                                            //                                            $j.post('actionM300.jsp?action=sendSMS&pn100='+pn100+'&phone='+phone+'&mv302='+mv302+'&mv305='+mv305+'&mv306='+mv306,function(data){
                                            //                                               
                                            //                                                if(data !=null){
                                            //                                                    $j('.success').text('GỬI THÀNH CÔNG !');
                                            //                                                }
                                            //                                            });
                                        },
                        						
                                        success: function( strData ){
                                                        
                                        }
                                    });							
                              
                                }
                      
                            });
                            
                       
                        }else{
                            $j('.success').text('VUI LÒNG KIỂM TRA LẠI NỘI DUNG !');
                        }                  
                
                        if(mv302.length > 5){
                            $j('.success').text('');
                            $j.post('sendMoreSMS.jsp?action=sendMoreSMS&mv302='+mv302+'&mv305='+mv305,function(data){
                                if(data !=null){
                                    $j('.success').text('GỬI THÀNH CÔNG !');
                                }
                            });
                        }else{
                            $j('.success').text('VUI LÒNG KIỂM TRA LẠI NỘI DUNG !');
                        }
                               
                    });
                      
                   
                });
            </script>
            <style type="text/css">
                .fancyboxClose{
                    display: none !important;
                }
                .template_input{
                    float: left !important;
                    margin-left: 68px !important;
                    margin-top: 5px;
                }
                .edit_form_right {
                    float: left;
                    height: 230px;
                    overflow: auto;
                    width: 310px !important;
                }
                .del{
                    float:left;
                    margin-top:9px;
                }
                .fields_input span img{
                    float:left;
                    width:15px;
                    height:15px;
                }
                .fields_input{
                    margin-top: 6px!important;
                    margin-left:10px !important;
                    width: 97% !important;
                }


                .form_item_content{
                    margin-left: 0px !important;
                }
                .contentsms textarea{
                    float:left;
                    width:400px;
                    height: 90px;
                }
                .contentsmsmd textarea{
                    float:left;
                    width:400px;
                    height: 60px;
                }
                .contentsms{
                    padding-bottom: 3px;
                }
                .filterbg{
                    float:left;
                    background: #D1E1F1;
                    width:100%;
                    padding-top:4px;
                    padding-bottom: 10px;
                }
                .hten{
                    float: left;
                    font-weight: bold;
                    margin-top: 4px;
                    text-transform: uppercase;

                }
                .success{
                    color: red;
                    float: left;
                    margin-left: 200px;
                    position: relative;
                    text-align: center;
                    text-transform: uppercase;
                    margin-top:10px;
                    width:200px;
                }
                .phonemore{
                    float: left;
                    height: 43px;
                    overflow-y: auto;
                    width: 454px;
                    margin-bottom: 20px;
                }
                .note{
                    float: left;
                    font-style: italic;
                    left: 0;
                    margin-left: 136px;
                    margin-top:60px;
                    position: absolute;
                    width: 520px;
                }
            </style>
        </head>

        <body style=" float:left; width:auto; height:auto; margin:0px;">
            <f:loadBundle basename="#{environmentSession.localizationSource}" var="locale"/>
            <div class="returnss"></div>
            <h:inputHidden value="#{CustomerBean.pn100}" id="pn100"/>
            <a4j:form>

                <div class="popup" style="height:430px; width:600px">
                    <div class="popup-header">
                        <div class="title"><h:outputText value="SEND SMS"/></div>
                    </div>
                    <div class="popup-content">
                        <div class="main_content">
                            <div class="form_item_content" style="display: block;">

                                <div class="filterbg">
                                    <div class="fields_input ">
                                        <label><h:outputText value="DT Người nhận "/>:</label>  
                                        <div class="phonemore">
                                            <a4j:repeat value="#{m300Bean.listMail}" var="item">
                                                <h:outputText value="#{item.phone} " styleClass="hten phoneold" rendered="#{item.phone !=null}"/>
                                            </a4j:repeat>
                                        </div>
                                    </div>
                                    <h:outputText styleClass="note" value="Chú ý mỗi số điện thoại cách nhau dấu phẩy (0932413788,01267175275)"/>
                                    <div class="fields_input">
                                        <label><h:outputText value="(+) " style="font-weight:bold;"/></label>
                                        <h:inputText value="" styleClass="hten addphone" style="width:400px;height:23px;"/>


                                    </div>

                                </div>
                                <div class="fields_input contentsms">
                                    <label><h:outputText value="Nội dung"/></label>

                                    <h:inputTextarea value="#{m300Bean.mv302}" styleClass="messagesms mv302"/>
                                </div>
                                <div class="filterbg">
                                    <div class="fields_input contentsmsmd">
                                        <label><h:outputText value="Mục đích:"/></label>
                                        <h:inputTextarea value="#{m300Bean.mv305}" styleClass="mv305" />
                                    </div>
                                </div>
                            </div>
                            <div class="success"></div>
                        </div>

                    </div>
                    <div class="popup-footer">
                        <h:inputHidden value="#{m300Bean.stephide}" id="step"/>
                        <h:inputHidden value="#{m300Bean.fk400}" id="fk400"/>
                        <h:panelGroup rendered="#{m300Bean.stephide ==1}"><div class="buttonsave close loadpage" style="margin-right: 66px;" onclick="closePopup();" lang="cuscompany.jsp?tab=tab2<h:outputText value="#{m300Bean.fk400}"/>&flag=<h:outputText value="#{m300Bean.timezone}"/>&#<h:outputText value="#{m300Bean.fk400}"/>" ><span><h:outputText value="#{locale.close}"/></span></div></h:panelGroup>
                         <h:panelGroup rendered="#{m300Bean.stephide ==9}"><div class="buttonsave close loadpage" style="margin-right: 66px;" onclick="closePopup();" lang="employee.jsp?action=reload&fn850=<h:outputText value="#{m300Bean.fn850}"/>" ><span><h:outputText value="#{locale.close}"/></span></div></h:panelGroup>
                         <h:panelGroup rendered="#{m300Bean.stephide ==2}"><div class="buttonsave close loadpage" style="margin-right: 66px;" onclick="closePopup();" lang="cuscompany.jsp?tab=tab3<h:outputText value="#{m300Bean.fk400}"/>&flag=<h:outputText value="#{m300Bean.timezone}"/>&#<h:outputText value="#{m300Bean.fk400}"/>" ><span><h:outputText value="#{locale.close}"/></span></div></h:panelGroup>
                        <h:panelGroup rendered="#{m300Bean.stephide !=1 && m300Bean.stephide !=2 && m300Bean.stephide !=9}"><div class="buttonsave close loadpage" style="margin-right: 66px;" onclick="closePopup();" lang="<h:outputText value="#{m300Bean.s}.jsp?type=#{m300Bean.ni104}&pk400=#{m300Bean.fk400}&dayss=#{m300Bean.dayss}"/>" ><span><h:outputText value="#{locale.close}"/></span></div></h:panelGroup>
                        <a4j:commandButton  onclick="showPleaseWait();" oncomplete="hidePleaseWait();" value="#{locale.save}" styleClass="buttonsave sendsmsexe" lang="#{CustomerBean.nv961}">

                        </a4j:commandButton>

                    </div>
                </div>
            </a4j:form>
            <rich:modalPanel id="ajaxLoadingModalBox" minHeight="30" minWidth="40"
                             height="30" width="40" zindex="2000">
                <h:outputText value="#{locale.please_wait}" styleClass="startDummer"></h:outputText>
            </rich:modalPanel>
        </body>
    </html>
    <script type="text/javascript">
         function closePopup(){
            page =  $j('.loadpage').attr('lang')
            //            alert(page);
            //            parent.$.fancybox.close();
            window.location =page;
            //       parent.jQuery.fancybox.close();
            //alert('aaa');
        }
        $j(document).ready(function(){
            yhight = ($j('.popup').height()-90)+"px" ;
            $j('.main_content').css('height',yhight );
            $j('.popup-content').css('height',yhight );
        });
    </script>
</f:view>